﻿<!DOCTYPE html>
<!--岗位安全职责考核管理编辑-->
<html>

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <script src="/static/js/common.js"></script>
    <link href="/static/js/vue-treeselect/vue-treeselect.css" rel="stylesheet" />
    <script src="/static/js/vue-treeselect/vue-treeselect.js"></script>
    <style>
        .vue-treeselect__control {
            height: 100%;
            border: none;
            background: none;
        }

        .vue-treeselect__placeholder {
            top: -3px;
        }

        .vue-treeselect__single-value {
            top: -3px;
        }
    </style>
    <style>
        /*说明：
         由于mystyle.css中162行.el-form-item__content {line-height: normal!important;}导致的
         index.css中.el-form-item--mini .el-form-item__content, .el-form-item--mini .el-form-item__label{    line-height: 28px;}失效
         但出于无法修改样式表的情况，所以在该页面添加以下样式，以保证页面内标题和内容不偏离
        */
        .el-form-item--mini .el-form-item__content,
        .el-form-item--mini .el-form-item__label {
            line-height: 28px !important;
        }

        .el-dialog__body {
            height: 200px;
        }
    </style>
    <style>

        .el-input__suffix {
            /* z-index: 9; */
        }

        .cell {
            text-align: center;
        }
    </style>
    <style>
        /*页面内弹窗导致function.js的响应式样式失效，懒得调了，单独写个死样式控制select的样式，勉强能用*/
        .input-with-select .el-input-group__append {
            background-color: #fff;
        }

        .el-input__inner {
            padding: 0px;
            margin: 0px;
            border-right: none;
        }

        .el-input--suffix .el-input__inner {
            padding-left: 30px;
        }

        .el-input-group__append {
            width: 100%;
        }
    </style>
    <style>

        .widthZ .el-input__inner {

            padding: 0px !important;
        }
        /*.widthZ .el-input-group__prepend {
            width: 150px !important;
        }*/

        .widthZ .el-select {
            width: 100% !important;
        }

        .widthZ .el-input-group__append {
            background-color: white;
            /*width: 66% !important;*/
            width: 62% !important;
        }

        .widthZ .el-select .el-input__inner {
            width: 100% !important;
        }
    </style>
</head>

<body>
    <div id="app" v-cloak class="popupW150">
        <el-form :model="Form" state-icon :rules="rules" ref="ruleForm" label-width="100px" size="mini"
                 label-position="right">
            <el-row>
                <el-col :span="11">
                    <div class="elst-select-mini">
                        <el-form-item>
                            <el-input type="text" v-model="Form.theme" autocomplete="off" size="mini">
                                <template slot="prepend">
                                    {{PostSafeResponsibilityExamineManager.assessmentSubject+mark.m}}
                                </template>
                            </el-input>
                            <span class="iputLineMust" v-if="!Form.theme">
                                <!-- 必填项添加 -->
                                <img src="/static/images/exclamation.png" alt="">
                            </span>
                        </el-form-item>
                    </div>
                </el-col>

                <el-col :span="11" offset="2">
                    <div class="elst-select-mini">
                        <el-form-item>
                            <el-input size="mini">
                                <template slot="prepend">
                                    {{PostSafeResponsibilityExamineManager.year+mark.m}}
                                </template>
                                <el-date-picker v-model="Form.assessmentYear" type="year" slot="suffix" format="yyyy"
                                                value-format="yyyy" size="mini" placeholder="选择日期"  @change="postChange1">
                                </el-date-picker>
                            </el-input>
                            <span class="iputLineMust" v-if="!Form.assessmentYear">
                                <!-- 必填项添加 -->
                                <img src="/static/images/exclamation.png" alt="">
                            </span>
                        </el-form-item>
                    </div>
                </el-col>
            </el-row>
            <el-row>

                <el-col :span="11">
                    <div class="elst-select-mini">
                        <el-form-item>
                            <el-input class="widthZ" size="mini">
                                <template slot="prepend">
                                    {{PostSafeResponsibilityExamineManager.post+mark.m}}
                                </template>
                                <el-select @visible-change="visibleChange" v-model="dutyId" slot="append" placeholder="请选择" @change="postChange">
                                    <el-option label="请选择" value=""></el-option>
                                    <el-option v-for="item in duties" :label="item.name" :value="item.id"></el-option>
                                </el-select>

                            </el-input>
                            <span class="iputLineMust" v-if="!dutyId">
                                <!-- 必填项添加 -->
                                <img src="/static/images/exclamation.png" alt="">
                            </span>
                        </el-form-item>
                    </div>

                </el-col>
                <el-col :span="11" offset="2">
                    <div class="elst-select-mini">
                        <el-form-item>
                            <el-input size="mini">
                                <template slot="prepend">
                                    {{'选择部门'+mark.m}}
                                </template>

                                <treeselect v-model="departmentId" :options="department" :flat="true"
                                            slot="suffix" placeholder="请选择"
                                            style="line-height: 28px;" />
                            </el-input>
                        </el-form-item>
                    </div>
                </el-col>
            </el-row>


            <el-row>
                <el-col :span="24">
                    <div class="elst-select-mini">
                        <el-form-item>
                            <div class="el-input--mini el-input-group">
                                <div class="el-input-group__prepend">
                                    {{PostSafeResponsibilityExamineManager.postSafeProductionScope+mark.m}}
                                </div>
                                <el-input class="el-textarea__inner" type="textarea" v-model="Form.postSafeProductionScope"
                                          autocomplete="off"></el-input>
                                <span class="iputLineMust" v-if="!Form.postSafeProductionScope">
                                    <!-- 必填项添加 -->
                                    <img src="/static/images/exclamation.png" alt="">
                                </span>
                            </div>
                        </el-form-item>
                    </div>
                </el-col>

            </el-row>
            <el-row>
                <el-col :span="24">
                    <div class="elst-select-mini">
                        <el-form-item>
                            <div class="el-input--mini el-input-group">
                                <div class="el-input-group__prepend">
                                    {{"岗位人员"+mark.m}}
                                </div>
                                <el-input class="el-textarea__inner" type="textarea" v-model="usersStr"
                                          autocomplete="off"></el-input>
                            </div>
                        </el-form-item>
                    </div>
                </el-col>

            </el-row>
            <el-row>
                <el-col :span="24">
                    <div class="elst-select-mini">
                        <el-form-item>
                            <div class="el-input--mini el-input-group">
                                <div class="el-input-group__prepend">
                                    {{user.remarks+mark.m}}
                                </div>
                                <el-input class="el-textarea__inner" type="textarea" v-model="Form.remark"
                                          autocomplete="off"></el-input>
                            </div>
                        </el-form-item>
                    </div>
                </el-col>

            </el-row>
            <!--<el-table ref="table" v-if="showTable" :data="Form.jG_JobsAssessDetail" :row-key="getRowKeys" border
              @selection-change="handleSelectionChange" row-style="height:10px" style="width: 100%;">
        <el-table-column type="index" :label="PostSafeResponsibilityExamineManager.id" :index="indexMethod"
                         width="60" show-overflow-tooltip="true"></el-table-column>
        <el-table-column prop="postSafeProductionContent"
                         :label="PostSafeResponsibilityExamineManager.postSafeProductionContent" show-overflow-tooltip="true"
                         width="300">
        </el-table-column>
        <el-table-column prop="assessmentContent"
                         :label="PostSafeResponsibilityExamineManager.assessmentContent" show-overflow-tooltip="true"
                         width="100">
        </el-table-column>
        <el-table-column prop="weightScore" :label="PostSafeResponsibilityExamineManager.weight"
                         show-overflow-tooltip="true" width="100">
        </el-table-column>
        <el-table-column prop="effectAndDescription"
                         :label="PostSafeResponsibilityExamineManager.effectAndDescription" show-overflow-tooltip="true">
            <template slot-scope="scope">
                <el-input v-model="scope.row.effectAndDescription" size="mini"
                          placeholder="工作效果和评估描述" class="weightScore">
                </el-input>
            </template>
        </el-table-column>
        <el-table-column prop="score" :label="PostSafeResponsibilityExamineManager.score"
                         show-overflow-tooltip="true" width="100">
            <template slot-scope="scope">
                <el-input v-model="scope.row.score" size="mini"
                          placeholder="评分" class="weightScore"></el-input>
            </template>
        </el-table-column>
    </el-table>-->





            <el-row type="flex" justify="end" style="margin-top:20px;">
                <el-form-item>
                    <el-button type="primary" @click="onSubmitForm('ruleForm','0')">{{col.btnSave}}</el-button>
                    <el-button type="primary" @click="onSubmitForm('ruleForm','1')">{{col.btnSubmit}}</el-button>
                    <el-button type="primary" @click="parent.ListItem.dialogVisible=false">{{col.btnBack}}</el-button>
                </el-form-item>
            </el-row>
        </el-form>

    </div>
    <script type="text/javascript">
        Vue.component('treeselect', VueTreeselect.Treeselect)
        app = new Vue({
            el: '#app',
            data: {
                //父业传参
                id: '',
                //mydata:[],// UsersTree,
                //业务表单内容
                Form: {
                    id: guidEmpty,
                    //postPerson:'',
                    //mark04: '',
                    createDept:'',
                    postNameID: '',
                    //theme:'',
                    //assessmentSubject:'',
                    //assessmentYear: '',
                    //postSafeProductionScope: '',
                    state:'0',
                    //jG_JobsAssessDetail: [],
                    //tableData:[],
                },
                //部门数据集
                department: [],
                //职务数据集
                duties: [],
                //部门model
                departmentId: null,
                //职务model
                dutyId: null,
                //选择部门后的信息对象
                deparmentObject: null,
                ////岗位集合
                //post: [],
                //人员集合
                users: [],
                usersStr:'',
                //考核
                jG_JobsAssess: { jobsAssessTask: '', postPerson: '', status: '0', jG_JobsAssessDetail:[]},
                ////表格显示开关
                //showTable: true,
                //表单验证
                rules: {
                    theme: [
                        verification.NotNull,
                    ], 
                    assessmentYear: [
                        verification.NotNull,
                    ],
                    postSafeProductionScope: [
                        verification.NotNull,
                    ],
                }
            },
            //watch: {
            //    //下拉树监控
            //    departmentId(val, oldval) {
            //        //初始化职务选项
            //        if (this.id == null) {
            //            this.dutyId = null;
            //        }
            //        //获取部门信息（含中间表及职务数据）
            //        this.getDuty(val);
            //        //绑定职务下拉框
            //        this.duties = this.deparmentObject.sysDepartmentDuties;
            //    }
            //},
            methods: {
                //解決edge下select bug
                visibleChange: function (isVisible) {
                    visibleChange(isVisible)
                },
                //表格序号连续化
                indexMethod: function (index) { return index + 1; },
                //提交数据
                //onSubmitForm: function (formName) {
                //    var mythis = this;
                //    this.$refs[formName].validate(function (valid) {
                //        //验证通过
                //        if (valid) {
                //            mythis.Form.state = state;
                //            mythis.Form.postID = mythis.departmentId;
                //            mythis.Form.postNameID = mythis.dutyId;
                //            //mythis.Form.theme = mythis.Form.assessmentSubject
                //            //mythis.Form.jG_JobsAssessDetail = mythis.Form.tableData
                //            onSubmitForm(this, '/api/JG_JobsAssess/Save', mythis.Form);
                //        } else {
                //            //验证失败
                //            return false;
                //        }
                //    });

                //},
                onSubmitForm: function (formName, state) {
                    var mythis = this;
                    
                    this.$refs[formName].validate(function (valid) {
                        //验证通过
                        if (valid) {

                            if (mythis.Form.theme == null || mythis.Form.theme == "" || mythis.Form.theme == undefined) {
                                alert('请输入考核主题');
                                return false;
                            }
                            if (mythis.Form.postSafeProductionScope == null || mythis.Form.postSafeProductionScope == "" || mythis.Form.postSafeProductionScope == undefined) {
                                alert('请输入岗位安全生产责任范围');
                                return false;
                            }
                            if (mythis.Form.assessmentYear == null || mythis.Form.assessmentYear == "" || mythis.Form.assessmentYear == undefined) {
                                alert('请选择年份');
                                return false;
                            }
                            if (mythis.dutyId == null || mythis.dutyId == "" || mythis.dutyId == undefined) {
                                alert('请选择岗位');
                                return false;
                            }
                            if (mythis.users == null || mythis.users.length==0) {
                                alert('该岗位没有人员');
                                return false;
                            }
                            mythis.Form.assessmentYear = mythis.Form.assessmentYear.toString().substring(0, 4) + "-01-01 00:00:00.000";
                            mythis.Form.state = state;
                            mythis.Form.createDept = mythis.departmentId;
                            mythis.Form.postNameID = mythis.dutyId;
                            mythis.Form.postID = mythis.departmentId;
                            
                            if (mythis.id != null) {
                                mythis.Form.id = mythis.id;
                                if (state == "0") {
                                    onSubmitForm(this, '/api/JG_JobsAssessTask/Save', mythis.Form);
                                    //执行完毕
                                    showMessage(msg.OperatingOk, 'success');
                                    parent.app.ListItem.dialogVisible = false;
                                } else {
                                    myAjax("post", mythis, '/api/JG_JobsAssessTask/Save', mythis.Form, function (response1) {
                                    //当前考核是否存在
                                    myAjax("post", this, '/api/JG_JobsAssess/GetList', { model: { jobsAssessTask: mythis.id}, offset: 0, limit: 10 }, function (response) {
                                        if (response.data.pageData.length == 0) {



                                            //获取考核模板
                                            myAjax("post", this, '/api/JG_JobsAssessTemplate/get', { model: { postID: mythis.Form.postNameID }, offset: 0, limit: 10 }, function (response2) {
                                                if (response2.data.pageData.length == 0) {
                                                    alert('此岗位没有考核模板,请换其他岗位');
                                                    return false;

                                                } else {
                                                    var list = response2.data.pageData[0].jG_JobsAssessTemplateDetail;


                                                    //循环岗位用户
                                                    for (var i = 0; i < mythis.users.length; i++) {
                                                        //主表
                                                        var jobsAssess = mythis.jG_JobsAssess;
                                                        //jobsAssessTask: '', postPerson: '', status: '0', jG_JobsAssessDetail:[]
                                                        jobsAssess.jobsAssessTask = mythis.id;
                                                        jobsAssess.postPerson = mythis.users[i].id;
                                                        jobsAssess.status = '0';
                                                        myAjax("post", mythis, '/api/JG_JobsAssess/Save', jobsAssess, function (response3) {
                                                            var jobsAssessId = response3.data; //任务ID
                                                            //jobsAssess.jG_JobsAssessDetail = [];
                                                            //循环考核明细
                                                            for (var j = 0; j < list.length; j++) {
                                                                var jG_JobsAssessDetail = {
                                                                    jGJobsAssessID: jobsAssessId,//考核主表id
                                                                    postSafeProductionContent: list[j].postSafeProductionContent,//岗位安全生产责任内容
                                                                    assessmentContent: list[j].assessmentContent,//考核内容
                                                                    weightScore: list[j].weightScore,//权重分
                                                                    effectAndDescription: '',//评估描述
                                                                    score: 0,//评分
                                                                };
                                                                myAjax("post", mythis, '/api/JG_JobsAssessDetail/Save', jG_JobsAssessDetail, function (response4) {
                                                                });
                                                            }


                                                        }, false);
                                                    }
                                                    //执行完毕
                                                    showMessage(msg.OperatingOk, 'success');
                                                    parent.app.ListItem.dialogVisible = false;

                                                }

                                            }, false);


                                        } else {
                                            //执行完毕
                                            showMessage(msg.OperatingOk, 'success');
                                            parent.app.ListItem.dialogVisible = false;
                                        }
                                    });  

                                    });  
                                }
                            } else {
                                if (state == "0") {
                                    onSubmitForm(this, '/api/JG_JobsAssessTask/Save', mythis.Form);
                                } else {
                                    //当前考核是否存在
                                    myAjax("post", this, '/api/JG_JobsAssessTask/GetList', { model: { assessmentYear: mythis.Form.assessmentYear, postNameID: mythis.Form.postNameID }, offset: 0, limit: 10 }, function (response) {
                                        if (response.data.pageData.length == 0) {

                                            //获取考核模板
                                            myAjax("post", this, '/api/JG_JobsAssessTemplate/get', { model: { postID: mythis.Form.postNameID }, offset: 0, limit: 10 }, function (response2) {
                                                if (response2.data.pageData.length == 0) {
                                                    alert('此岗位没有考核模板,请换其他岗位');
                                                    return false;

                                                } else {
                                                    var list = response2.data.pageData[0].jG_JobsAssessTemplateDetail;
                                                    //新增任务
                                                    myAjax("post", mythis, '/api/JG_JobsAssessTask/Save', mythis.Form, function (response1) {
                                                        var taskId = response1.data; //任务ID

                                                        //循环岗位用户
                                                        for (var i = 0; i < mythis.users.length; i++) {
                                                            //主表
                                                            var jobsAssess = mythis.jG_JobsAssess;
                                                            //jobsAssessTask: '', postPerson: '', status: '0', jG_JobsAssessDetail:[]
                                                            jobsAssess.jobsAssessTask = taskId;
                                                            jobsAssess.postPerson = mythis.users[i].id;
                                                            jobsAssess.status = '0';
                                                            myAjax("post", mythis, '/api/JG_JobsAssess/Save', jobsAssess, function (response3) {
                                                                var jobsAssessId = response3.data; //任务ID
                                                                //jobsAssess.jG_JobsAssessDetail = [];
                                                                //循环考核明细
                                                                for (var j = 0; j < list.length; j++) {
                                                                    var jG_JobsAssessDetail = {
                                                                        jGJobsAssessID: jobsAssessId,//考核主表id
                                                                        postSafeProductionContent: list[j].postSafeProductionContent,//岗位安全生产责任内容
                                                                        assessmentContent: list[j].assessmentContent,//考核内容
                                                                        weightScore: list[j].weightScore,//权重分
                                                                        effectAndDescription: '',//评估描述
                                                                        score: 0,//评分
                                                                    };
                                                                    myAjax("post", mythis, '/api/JG_JobsAssessDetail/Save', jG_JobsAssessDetail, function (response4) {
                                                                    });
                                                                }


                                                            }, false);
                                                        }
                                                        //执行完毕
                                                        showMessage(msg.OperatingOk, 'success');
                                                        parent.app.ListItem.dialogVisible = false;
                                                    }, false);
                                                }

                                            }, false);


                                        } else {
                                            alert('已考核,请换其他岗位');
                                            return false;
                                        }

                                    });
                                }
                            }
                        }else {
                            //验证失败
                            return false;
                        }
                    });

                },
                getData: function () {
                    var mythis = this;
                    if (mythis.id != null && mythis.id != '') {
                        myAjax("get", mythis, '/api/JG_JobsAssessTask/get?id=' + this.id, null, function (response) {
                            var ajaxModel = response.data;
                            mythis.Form = ajaxModel;
                            mythis.departmentId = ajaxModel.postID;
                            mythis.dutyId = ajaxModel.postNameID;
                            //mythis.Form.assessmentSubject = ajaxModel.theme;
                            mythis.Form.postNameID = ajaxModel.postNameID;
                            mythis.Form.assessmentYear = mythis.Form.assessmentYear.toString().substring(0, 4);
                            //mythis.userFrom.sex = mythis.userFrom.sex + "";
                            //mythis.Form.tableData = ajaxModel.jG_JobsAssessDetail;
                            //获取岗位人员
                            myAjax("get", this, '/api/JG_JobsAssess/GetDutyUser?dutyID=' + mythis.dutyId, {}, function (response) {
                                if (response.data.length == 0) {

                                } else {
                                    mythis.users = response.data;
                                    for (var z = 0; z < mythis.users.length; z++) {
                                        mythis.usersStr = mythis.usersStr + mythis.users[z].name + "\r\n";
                                    }

                                }
                            }, false);
                            if (ajaxModel.postID == null) { } else {
                                myAjax("post", this, '/api/SysDepartment/GetList', { model: { id: ajaxModel.postID }, offset: 0, limit: 10 }, function (response) {
                                    mythis.department = menuHelper(response.data.pageData, guidEmpty);
                                    mythis.departmentId = ajaxModel.postID;

                                }, false);
                            }
                        }, false);
                    }
                },
                getSysDuty: function () {
                    var mythis = this;
                    myAjax("post", this, '/api/SysDuty/GetList', { model: { Name: '', CreateFactory: null }, offset: 0, limit: 10 }, function (response) {
                        mythis.duties = menuHelper(response.data.pageData, guidEmpty)
                    }, false);
                },
                postChange: function (val) {

                    var mythis = this;
                    //    if (mythis.id!=null) {
                    //        myAjax("post", this, '/api/JG_JobsAssessTemplate/get', { model: { postID: val }, offset: 0, limit: 10 }, function (response) {
                    //            if (response.data.pageData.length == 0) {
                    //                mythis.Form.jG_JobsAssessDetail = [];

                    //            } else {
                    //                //mythis.Form.id = response.data.pageData[0].id;
                    if (mythis.Form.assessmentYear == null || mythis.Form.assessmentYear == "" || mythis.Form.assessmentYear == undefined) { } else {
                        var obj = '';
                        for (var i = 0; i < this.duties.length; i++) {
                            if (this.duties[i].id == val) {
                                obj = this.duties[i];
                                break;
                            }
                        }

                        //console.log(obj.name)
                        mythis.Form.theme = mythis.Form.assessmentYear + '年' + obj.name + '岗位考核';
                        if (obj.sysDepartmentID == null) { } else {
                            myAjax("post", this, '/api/SysDepartment/GetList', { model: { id: obj.sysDepartmentID }, offset: 0, limit: 10 }, function (response) {
                                mythis.department = menuHelper(response.data.pageData, guidEmpty);
                                mythis.departmentId = obj.sysDepartmentID;
                                mythis.Form.jG_JobsAssessDetail = [];
                            }, false);
                        }
                        ////获取岗位上部门
                        //myAjax("post", this, '/api/JG_JobsAssess/GetDepartmentId', { model: { dutyID: val }, offset: 0, limit: 100 }, function (response) {
                        //    if (response.data.length == 0) {

                        //    } else {
                        //        mythis.departmentId = response.data;

                        //    }
                        //}, false);

                        //获取岗位人员
                        myAjax("get", this, '/api/JG_JobsAssess/GetDutyUser?dutyID=' + val, {}, function (response) {
                            if (response.data.length == 0) {

                            } else {
                                mythis.users = response.data;
                                mythis.usersStr = "";
                                for (var z = 0; z < mythis.users.length; z++) {
                                    mythis.usersStr = mythis.usersStr + mythis.users[z].name + "\r\n";
                                }

                            }
                        }, false);

                    }
                    ////                mythis.Form.theme = mythis.Form.assessmentYear + '年' + response.data.pageData[0].postSafeProductionContent + '岗位考核';

                    //                if (val) this.showTable = true
                    //                else this.showTable = false
                    //            }
                    //        }, false);

                    //    } else {
                    //        var tableData = [];
                    //        myAjax("post", this, '/api/JG_JobsAssessTemplate/get', { model: { postID: val }, offset: 0, limit: 10 }, function (response) {
                    //            if (response.data.pageData.length == 0) {
                    //                mythis.Form.jG_JobsAssessDetail = [];

                    //            } else {
                    //                //mythis.Form.id = response.data.pageData[0].id;
                    //                mythis.Form.theme = mythis.Form.assessmentYear + '年' + response.data.pageData[0].postSafeProductionContent + '岗位考核';
                    //                var list = response.data.pageData[0].jG_JobsAssessTemplateDetail
                    //                for (var j = 0; j < list.length; j++) {
                    //                    tableData.push({
                    //                        postSafeProductionContent: list[j].postSafeProductionContent,//岗位安全生产责任内容
                    //                        assessmentContent: list[j].assessmentContent,//考核内容
                    //                        weightScore: list[j].weightScore,//权重分
                    //                        effectAndDescription: '',//评估描述
                    //                        score: 0,//评分
                    //                    })
                    //                }
                    //                mythis.Form.jG_JobsAssessDetail = tableData;

                    //                if (val) this.showTable = true
                    //                else this.showTable = false
                    //            }
                    //        }, false);
                    //    }


                },
                postChange1: function (val) {

                    var mythis = this;
                    //    if (mythis.id!=null) {
                    //        myAjax("post", this, '/api/JG_JobsAssessTemplate/get', { model: { postID: val }, offset: 0, limit: 10 }, function (response) {
                    //            if (response.data.pageData.length == 0) {
                    //                mythis.Form.jG_JobsAssessDetail = [];

                    //            } else {
                    //                //mythis.Form.id = response.data.pageData[0].id;
                    var obj = '';
                    if (mythis.dutyId == null || mythis.dutyId == '' || mythis.dutyId == undefined) { } else {
                    for (var i = 0; i < mythis.duties.length; i++) {
                        if (mythis.duties[i].id == mythis.dutyId) {
                            obj = mythis.duties[i];
                            break;
                        }
                    }
                    
                        //console.log(obj.name)
                        mythis.Form.theme = val + '年' + obj.name + '岗位考核';
                        if (obj.sysDepartmentID == null) { } else {
                            myAjax("post", this, '/api/SysDepartment/GetList', { model: { id: obj.sysDepartmentID }, offset: 0, limit: 10 }, function (response) {
                                mythis.department = menuHelper(response.data.pageData, guidEmpty);
                                mythis.departmentId = obj.sysDepartmentID;
                                mythis.Form.jG_JobsAssessDetail = [];
                            }, false);
                        }


                        //获取岗位人员
                        myAjax("get", this, '/api/JG_JobsAssess/GetDutyUser?dutyID=' + mythis.dutyId, {}, function (response) {
                            if (response.data.length == 0) {

                            } else {
                                mythis.users = response.data;
                                mythis.usersStr = "";
                                for (var z = 0; z < mythis.users.length; z++) {
                                    mythis.usersStr = mythis.usersStr + mythis.users[z].name + "\r\n";
                                }

                            }
                        }, false);


                    }

                },
                // getDepartmentUserData: function () {
                //    var mythis = this;
                //    myAjax("post", this, '/api/JG_JobsAssess/GetDepartmentUserList', { model: {}, offset: 0, limit: 99999 }, function (response) {

                //        if (response.data == null || response.data.length == 0) {
                //            mythis.users = []
                //        } else {
                //            mythis.users = menuHelper(response.data, guidEmpty)
                //        }
                //    }, false);

                //},
                ////初始化部门下拉树(完成)
                //getDepartmentData: function () {
                //    var mythis = this;
                //    myAjax("post", this, '/api/SysDepartment/GetList', { model: { Name: '', Code: '', CreateFactory: null }, offset: 0, limit: 10 }, function (response) {
                //        mythis.department = menuHelper(response.data.pageData, guidEmpty);
                //        mythis.Form.jG_JobsAssessDetail = [];
                //    }, false);

                //},
                //联动职务下拉框(完成)
                getDuty: function (pid) {
                    var mythis = this;
                    myAjax("get", mythis, '/api/SysDepartment/Get?id=' + pid, null, function (response) {
                        console.log(' response.data', response.data)
                        mythis.deparmentObject = response.data;

                    }, false);
                },
            },
            mounted: function () {
                ////初始化部门下拉树数据
                //this.getDepartmentData();
                //初始化岗位
                this.getSysDuty();
                //this.getDepartmentUserData();
                //this.post = getDicData('postname');
                //this.users = fn(this.mydata, "0");
                this.id = getUrlParam("id");
                this.getData();
                if (this.Form.post) {
                    this.showTable = true;
                }
                console.log('this.Form', this.Form)
            }
        });
        //下拉树数据格式化
        function menuHelper(list, pid) {
            var result = [];
            if (list.length <= 0)
                return list;
            list.forEach(function (v, i) {
                var temp = {};
                for (var key in v) {
                    temp[key] = v[key];
                }
                temp.label = v.name;
                temp.parentId = temp.parentId ? temp.parentId : guidEmpty;
                var obj;
                if (temp.parentId == pid) {
                    obj = temp;
                    var nextObj = menuHelper(list, temp.id);
                    if (nextObj.length > 0) {
                        obj.children = nextObj;
                    }
                }
                if (obj)
                    result.push(obj)
            })
            return result;
        }
    </script>
</body>

</html>